package com.yymagicer.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yymagicer.entity.WorkEntity;
import com.yymagicer.service.IWorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yymagicer.domain.QueryWork;

import java.util.List;

/**
 * <p>Description: some description </p>
 *
 * @author : xiaodong.yang
 * @date : 2023/12/22 16:41
 */
@RestController
@RequestMapping("/work")
public class WorkController {

    @Autowired
    private IWorkService workService;

    /**
     * 查询
     *
     * @param queryWork
     * @return
     */
    @GetMapping
    public List<WorkEntity> query(QueryWork queryWork) {
        LambdaQueryWrapper<WorkEntity> queryWrapper = Wrappers.lambdaQuery(WorkEntity.class);
        if (StringUtils.isNotBlank(queryWork.getCreateTime())) {
        }

        return workService.list();
    }

    /**
     * 新增
     *
     * @param workEntity
     * @return
     */

    @PostMapping
    public Boolean add(@RequestBody WorkEntity workEntity) {
        return workService.save(workEntity);
    }

    /**
     * 修改
     *
     * @param workEntity
     * @return
     */
    @PutMapping
    public Boolean update(@RequestBody WorkEntity workEntity) {
        return workService.updateById(workEntity);
    }

    /**
     * 删除
     *
     * @param workEntity
     * @return
     */
    @DeleteMapping
    public Boolean delete(@RequestBody WorkEntity workEntity) {
        return workService.removeById(workEntity);
    }

}
